
_       = require 'lodash'
log4js  = require 'log4js'
async   = require 'async'
mongoose = require 'mongoose'

require './init'

nx  = require './number-x'


logger = log4js.getLogger()

chars = 'abcdefghijklmnopqrstuvwxyz'

fno = nx.to10 'xaaa', chars
tno = nx.to10 'zzzz', chars
ls = _.map [fno..tno], (i) -> key: nx.toStr i, chars

# https://domains.qcloud.com/model/check_domains?domain=dwdcv&tlds=.com
iter = (m, cb) ->
  M = mongoose.model 'domain'
  q = M.findOneAndUpdate {key: m.key}, m, {upsert:yes}
  q.exec (err, mm) ->
    logger.error err if err
    cb null

async.each ls, iter, (err) ->
  mongoose.disconnect()




